<?php
App::import('Controller','Admin');
class ProductTypeController extends AdminController {

    /**
     * 
     */
    public function index() {
        $this->loadModel('ProductType');
        $this->set('result',$this->ProductType->find('all'));
    }
    
    /**
     * 
     */
    public function edit($id = null){
        $this->loadModel('Property');
        $this->loadModel('ProductType');
        if($this->request->data){
            if($id != null)
                $this->ProductType->id = $id;
            if($this->ProductType->save($this->request->data)){
                $this->Session->setFlash(__('Your product type has been saved.'), 'alert', array('plugin' => 'BoostCake','class' => 'alert-success'));
            }
        }
        $this->loadModel('Property');
        $properties = $this->Property->getAllProperty();
        $this->set('properties',$properties);
        
        
        if(!$this->request->data && $id != null){
            $this->request->data = $this->ProductType->getDetailProductType($id);
            //echo "<pre>";var_dump($this->request->data);die();
        }
    }
	/**
     * DELETE
     */
	public function deleteproducttype($id) {
        $this->ProductType->delete($id);
        $this->Session->setFlash(__('Delete Products Type success.'), 'alert', array('plugin' => 'BoostCake', 'class' => 'alert-success'));
        return $this->redirect(array('action' => 'index'));
    }

}